package com.chen.manager.service.impl;

import com.chen.manager.mapper.ProductSpecMapper;
import com.chen.manager.service.ProductSpecService;
import com.chen.model.entity.product.ProductSpec;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author cgj
 * @date 3/9/25 3:03 PM
 */
@Service
@Transactional
public class ProductSpecServiceImpl implements ProductSpecService {
   @Autowired
   private ProductSpecMapper productSpecMapper;
    @Transactional(readOnly = true)
    @Override
    public PageInfo<ProductSpec> selectByPage(Integer pageNum, Integer pageSize) {
        List<ProductSpec> specList=productSpecMapper.selectByPage();
        return new PageInfo<>(specList);
    }

    /**
     * 新增
     */
    @Override
    public void save(ProductSpec productSpec) {
         productSpecMapper.insertProductSpec(productSpec);
    }

    @Override
    public void updateProductSpec(ProductSpec productSpec) {
        productSpecMapper.updateProductSpec(productSpec);
    }

    /**
     * 根据id删除
     * @param id
     */
    @Override
    public void deleteById(Long id) {
        productSpecMapper.deleteById(id);
    }

    /**
     * 查询全部商品规格
     * @return
     */
    @Transactional(readOnly = true)
    @Override
    public List<ProductSpec> selectAll() {
        return productSpecMapper.selectByPage();
    }
}
